import { config } from "./config.js";
import HighCharts from "highcharts";
import HighChartsExport from "highcharts/modules/exporting";
HighChartsExport(HighCharts);
var vm = "";
HighCharts.setOptions({
  lang: config.lang
});
var dafaultMenuItem = HighCharts.getOptions().exporting.buttons.contextButton
  .menuItems;

export function createLineChart(sensorData,sensorTime) {
      vm = this;
      var lineChartsOptions = {
        chart: {
            type: 'line'
        },
        title: {
            text: '土壤监测趋势图'
        },
        xAxis: {
            categories: sensorTime
        },
        yAxis: {
            title: {
                text: '湿度（%）'
            }
        },
        plotOptions: {
            line: {
                dataLabels: {
                    enabled: true          // 开启数据标签
                },
                enableMouseTracking: false // 关闭鼠标跟踪，对应的提示框、点击事件会失效
            }
        },
        series: [{
            name: '土壤湿度',
            data: sensorData
        }]
      };
      var lineChart = new HighCharts.chart("line", lineChartsOptions);
      // lineChart.update({
      //   plotOptions: {
      //       bar: {
      //           point: {
      //               events: {
      //                   click: function(e) { // 同样的可以在点击事件里处理
      //                       vm.activeName = 'third'
      //                   }
      //               }
      //           },
      //       }
      //   }
      // })
}